import pygame, sys, os
import Menu, Config


#load everything more, check out other constants.py from bullet hell


pygame.init()


PRINT_FPS = False
FPS = 60


resolution = (640,480)
screen = pygame.display.set_mode(resolution)
pygame.display.set_caption("?")

black = pygame.Surface(resolution)
black.fill((0,0,0))

CHANGEMOUSE = False
GRABEVENTS = False
HIDEMOUSE = False


#clue

CLUE_FIRST_CLUE_HEIGHT = 64
CLUE_LEFT_MARGIN = 100
CLUE_NEXT_CLUE = 48



#map




#puzzle

PUZZLE_LEFT_MARGIN = 64
PUZZLE_TOP_MARGIN = 64
PUZZLE_GRID_WIDTH = 64
PUZZLE_GRID_HEIGHT = 64

PUZZLE_IMAGES = {
	"unit": pygame.image.load(os.path.join("images", "puzzleunit.png")).convert_alpha(),
	"border": pygame.image.load(os.path.join("images", "puzzleblockborder.png")).convert_alpha(),
}

PUZZLE_UNIT_SIZE = PUZZLE_IMAGES["unit"].get_width()
PUZZLE_BORDER_SIZE = PUZZLE_IMAGES["border"].get_width()


#escape

ESCAPE_BG_SPD = .75
ESCAPE_FLOOR_SPD = 2
ESCAPE_PLAYER_MIN_SPD = .625
ESCAPE_PLAYER_SLOW_SPD = 1.25
ESCAPE_PLAYER_DEFAULT_SPD = 1.5
ESCAPE_PLAYER_MAX_SPD = 1.75
ESCAPE_PLAYER_ACCEL = .0075
ESCAPE_PLAYER_RUN_FRAME_DELAY = 8
ESCAPE_PLAYER_RUN_FRAMES = 7
ESCAPE_PLAYER_JUMP_FRAME_ID = 7

ESCAPE_QUESTION_RATE = 240
ESCAPE_QUESTION_ACCEL = 5
ESCAPE_SLOW_DISTANCE = 75
ESCAPE_GOAL_DISTANCE = 10000

ESCAPE_PLAYER_SCREEN_TETHER = resolution[0] / 2

ESCAPE_FIRST_NUMBER_LOC = (160,48)
ESCAPE_NEXT_NUMBER_LOC = (240,48)
ESCAPE_CURRENT_NUMBER_LOC = (400,48)


player_image = pygame.image.load(os.path.join("images", "animation_run.png")).convert_alpha()
p_width = 162
p_height = 185
player_sheet = (
	player_image.subsurface(0, 0, p_width, p_height),
	player_image.subsurface(p_width, 0, p_width, p_height),
	player_image.subsurface(p_width * 2, 0, p_width, p_height),
	player_image.subsurface(p_width * 3, 0, p_width, p_height),
	player_image.subsurface(p_width * 4, 0, p_width, p_height),
	player_image.subsurface(p_width * 5, 0, p_width, p_height),
	player_image.subsurface(p_width * 6, 0, p_width, p_height),
	# player_image.subsurface(p_width * 7, 0, p_width, p_height),
)

ESCAPE_IMAGES = {
	"player": player_sheet,
	"background": pygame.image.load(os.path.join("images", "background_rocks.png")).convert_alpha(),
	"floor": pygame.image.load(os.path.join("images", "floor.png")).convert_alpha(),
	"obstacle": pygame.image.load(os.path.join("images", "obstacle.png")).convert_alpha(),
}
ESCAPE_BG_WIDTH = ESCAPE_IMAGES["background"].get_width()
ESCAPE_BG_HEIGHT = ESCAPE_IMAGES["background"].get_height()
ESCAPE_FLOOR_WIDTH = ESCAPE_IMAGES["floor"].get_width()
ESCAPE_FLOOR_TOP = 378

#fonts, could use str keys
fonts = {
	24: pygame.font.Font(os.path.join("fonts", "freesansbold.ttf"), 24),
	32: pygame.font.Font(os.path.join("fonts", "freesansbold.ttf"), 32),
	48: pygame.font.Font(os.path.join("fonts", "freesansbold.ttf"), 48),
}


#sound: effects, music
sfx = {
	# "": os.path.join("sounds", "sfx", "something.wav"),
}
musics = {
	# "": os.path.join("sounds", "music", "something.wav/mid"),
}


#configurable options
config = Config.Config()


#menu/mode constants
QUIT = -1
MAIN_MENU = 0
HUB_SCREEN = 10
PRACTICE = 20

OPTIONS = 40
PAUSE_GAME = 90
RESET_GAME = 99

START_GAME = 100
START_CLUE = 101
START_MAP = 102
START_PUZZLE = 103
START_ESCAPE = 104



#menus
Menu.getstuff(None, fonts)
menus = {
	MAIN_MENU: Menu.Menu(("GO", "OPTIONS", "QUIT"), (HUB_SCREEN, OPTIONS, QUIT), 32, (0,0), 1, 16, (255,255,255), (255,0,0)),
	HUB_SCREEN: Menu.Menu(("NEW QUEST", "PRACTICE", "BACK"), (START_GAME, PRACTICE, MAIN_MENU), 32, (0,0), 1, 16, (255,255,255), (255,0,0)),
	PRACTICE: Menu.Menu(("CLUE", "MAP", "PUZZLE", "ESCAPE", "BACK"), (START_CLUE, START_MAP, START_PUZZLE, START_ESCAPE, HUB_SCREEN), 32, (0,0), 1, 16, (255,255,255), (255,0,0)),
	OPTIONS: Menu.Menu(("PRINT FPS", "BACK",), (50, MAIN_MENU,), 32, (0,0), 1, 16, (255,255,255), (255,0,0)),
	PAUSE_GAME: Menu.Menu(("RESUME", "RESET", "OPTIONS", "QUIT"), (START_GAME, RESET_GAME, OPTIONS, QUIT), 32, (0,0), 1, 16, (255,255,255), (255,0,0))
}




